package com.leetcode.math;

import java.util.ArrayList;
import java.util.List;

public class MaximumEvenSplit {
    public static void main(String[] args) {
        MaximumEvenSplit maximumEvenSplit = new MaximumEvenSplit();
        System.out.println(maximumEvenSplit.maximumEvenSplit(12));
    }

    public List<Long> maximumEvenSplit(long finalSum) {
        List<Long> resList = new ArrayList<>();
        if (finalSum % 2 != 0) {
            return resList;
        }
        for (long i = 2; i <= finalSum; i += 2) {
            resList.add(i);
            finalSum -= i;
        }
        resList.set(resList.size() - 1, resList.get(resList.size() - 1) + finalSum);

        return resList;
    }
}
